//
//  ljjiftTextField.ljjift
//  AiTouYun
//
//  Created by liujunjie on 2018/9/15.
//  Copyright © 2018年 junjie.liu. All rights reserved.
//

import UIKit

public extension UITextField {
    
    @discardableResult
    public  func ljj_placeholder(_ placeholder: String) -> UITextField {
        self.placeholder = placeholder
        return self
    }
    
    @discardableResult
    public func ljj_text(_ text: String) -> UITextField {
        self.text = text
        return self
    }
    
    @discardableResult
    public func ljj_textColor(_ textColor: UIColor) -> UITextField {
        self.textColor = textColor
        return self
    }
    
    @discardableResult
    public func ljj_placeHolderColor(_ placeHolderColor: UIColor) -> UITextField {
        self.setValue(placeHolderColor, forKeyPath: "_placeholderLabel.textColor")
        return self
    }
    
    @discardableResult
    public func ljj_placeHolderFont(_ placeHolderFont: CGFloat) -> UITextField {
        self.setValue(UIFont.systemFont(ofSize: placeHolderFont), forKeyPath: "_placeholderLabel.font")
        return self
    }
    
    @discardableResult
    public func ljj_backgroundColor(_ backgroundColor: UIColor) -> UITextField {
        self.backgroundColor = backgroundColor;
        return self
    }
    
    @discardableResult
    public func ljj_fontSize(_ fontSize: CGFloat) -> UITextField {
        self.font = UIFont.systemFont(ofSize: fontSize)
        return self
    }
    
    @discardableResult
    public func ljj_showSecureTextEntry(_ showSecureTextEntry: Bool) -> UITextField {
        self.isSecureTextEntry = showSecureTextEntry
        return self
    }
    
    @discardableResult
    public func ljj_borderStyle(_ borderStyles: UITextField.BorderStyle) -> UITextField {
        self.borderStyle = borderStyles
        return self
    }
    
    @discardableResult
    public func ljj_keyboardTypes(_ keyboardType: UIKeyboardType) -> UITextField {
        self.keyboardType = keyboardType
        return self
    }
    
    @discardableResult
    public func ljj_delegate(_ delegate: AnyObject) -> UITextField {
        self.delegate = delegate as? UITextFieldDelegate
        return self
    }
    
    @discardableResult
    public func ljj_border(_ color: UIColor, width: CGFloat) -> UITextField {
        self.layer.borderColor = color.cgColor
        self.layer.borderWidth = width
        self.layer.masksToBounds = true
        return self
    }
}
